﻿using System;
using System.Net;
using System.Xml.Linq;
using System.Linq;

namespace ArmoryBrowser.Entities
{
    public class Ranged
    {
        #region Fields
        private RangedWeaponSkill _weaponSkillField;
        private WeaponDamage _damageField;
        private WeaponSpeed _speedField;
        private Power _powerField;
        private HitRating _hitRatingField;
        private CritChance _critChanceField;
        #endregion
        #region Properties
        public RangedWeaponSkill WeaponSkill
        {
            get
            {
                return this._weaponSkillField;
            }
            set
            {
                this._weaponSkillField = value;
            }
        }

        public WeaponDamage Damage
        {
            get
            {
                return this._damageField;
            }
            set
            {
                this._damageField = value;
            }
        }

        public WeaponSpeed Speed
        {
            get
            {
                return this._speedField;
            }
            set
            {
                this._speedField = value;
            }
        }

        public Power Power
        {
            get
            {
                return this._powerField;
            }
            set
            {
                this._powerField = value;
            }
        }

        public HitRating HitRating
        {
            get
            {
                return this._hitRatingField;
            }
            set
            {
                this._hitRatingField = value;
            }
        }

        public CritChance CritChance
        {
            get
            {
                return this._critChanceField;
            }
            set
            {
                this._critChanceField = value;
            }
        }
        #endregion
        #region Constructor
        public Ranged(XElement element)
        {
            WeaponSkill = element.Elements("weaponSkill").Select(e => new RangedWeaponSkill(e)).FirstOrDefault();
            Damage = element.Elements("damage").Select(e => new WeaponDamage(e)).FirstOrDefault();
            Speed = element.Elements("speed").Select(e => new WeaponSpeed(e)).FirstOrDefault();
            Power = element.Elements("power").Select(e => new Power(e)).FirstOrDefault();
            HitRating = element.Elements("hitRating").Select(e => new HitRating(e)).FirstOrDefault();
            CritChance = element.Elements("critChance").Select(e => new CritChance(e)).FirstOrDefault();
        }
        #endregion
    }
}
